function showarticulos(dato,page){
    //alert(dato);
    
    $.ajax({
        type: "POST",
        url:'php/articulos.php',
        data: "id="+dato+"&page="+page,
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        success:function(data){
            $('#showProducts').html(data);
        }
    }) ;
    
}

function showcar(){
    $.ajax({
        url:'php/display_carro_compras_1.php',
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        success:function(data){
            $('#showProducts').html(data);
        }
    }) ;

}

function hacerPedido(){
    $.ajax({
        url:'php/procesa_pedido.php',
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        success:function(data){
            $('#showProducts').html(data);
            $('#shop_items').html("0");
        }
    }) ;
}


function borrar(dato){
    $.ajax({
        type: "POST",
        url:'php/elimina_item.php',
        data: "id="+dato,
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        success:function(data){
            var text=data.split('&');
            //alert(text[0]);
            $('#_art'+dato+'').remove();
            $('#shop_items').html(text[1]);
            $('#updArt').html(text[1]);
            $('#updto').html(text[0]);
            //if(text[0]=="OK"){
               // window.location="index.php";
            //}
        }
    }) ;
}


function update(dato){
    var nuevaQty = $('#qty_'+dato).val();
    
    $.ajax({
        type: "POST",
        url:'php/update_item.php',
        data: "id="+dato+"&cantidad="+nuevaQty,
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        success:function(data){
            var text=data.split('&');
            $('#qty_'+dato).attr('value',text[3]);
            $('#updprecio_'+dato).html(text[2]+'.00');
            $('#shop_items').html(text[1]);
            $('#updArt').html(text[1]);
            $('#updto').html(text[0]);
            
        }
    });
}


function refreshItems(dato,nuevo){
    
    $.ajax({
        type: "POST",
        url:'php/ver_carrito.php',
        data: "new="+nuevo,
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        success:function(data){
            $('#showProducts').html(data);
            $('#shop_items').html(dato+1);
        }
    }) ;
}


function fn_popupbox(variable,rev){
    variable+='?sid='+Math.random()

    variable+='&Remitente='+$("#Remitente").val()	//}

    $.popupbox.settings.opacity = 0.5;
    jQuery.popupbox({iframe: variable},rev);
}

